package com.example.lotterysystem.common.exception;

import com.example.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException{

    //异常错误码
    private Integer code;

    //异常错误消息
    private String message;

    //防止空序列化的问题
    public ServiceException(){

    }

    public ServiceException(Integer code,String message){
        this.code=code;
        this.message=message;
    }

    public ServiceException(ErrorCode errorCode){
        this.code=errorCode.getCode();
        this.message=errorCode.getMsg();
    }

}
